import type { BRule } from "./types.d.mts";
import preset from "./_presets.mjs";
import { unsafeWindow } from "tm";
import { alertLog } from "./buildConfig.mts";

export const data: {
  disabled: boolean;
  saved: boolean;
  update: boolean;
  updating: boolean;
  receivedRules: string;
  customRules: string;
  allRules: string;
  genHideCss: string;
  genExtraCss: string;
  spcHideCss: string;
  spcExtraCss: string;
  bRules: BRule[];
  appliedLevel: BRule["level"];
  appliedCount: number;
  isFrame: boolean;
  isClean: boolean;
  readonly mutex: string;
  preset: string;
  timeout: number;
  headTimeout: number;
  tryCount: number;
  tryTimeout: number;
  readonly alertLog: boolean;
  autoCleanSize: number;
  [key: string]: unknown;
} = {
  isFrame: unsafeWindow.self !== unsafeWindow.top,
  isClean: false,
  disabled: false,
  saved: false,
  update: true,
  updating: false,
  alertLog: alertLog ? confirm("要开启日志弹窗吗") : false,
  receivedRules: "",
  customRules: preset.userConfig.rules,
  allRules: "",
  genHideCss: "",
  genExtraCss: "",
  spcHideCss: "",
  spcExtraCss: "",
  bRules: [],
  appliedLevel: 0,
  appliedCount: 0,
  mutex: "__lemon__abp__parser__$__",
  preset: preset.userConfig.css,
  timeout: preset.userConfig.timeout,
  headTimeout: preset.userConfig.headTimeout,
  tryCount: preset.userConfig.tryCount,
  tryTimeout: preset.userConfig.tryTimeout,
  autoCleanSize: preset.userConfig.autoCleanSize,
};
